#pragma once

#include <windows.h>
#include <vector>
#include "ICheat.h"
#include "common.h"
#include "HotKey.h"
#include "ITrainer.h"

#include "SMemPatch.h"
#include "NopPatch.h"

namespace TLib
{
	class SCheat : public ICheat
	{
	protected:
		std::string name;
		bool enabled;
		std::vector<IMemPatch*> patches;
		HotKey* hotkey;
	public:
		TRAINER_LIB_API SCheat(const std::string& name, ITrainer* app);
		
		TRAINER_LIB_API SCheat(const std::string& name,
			ITrainer* app,
			std::vector<IMemPatch*>& patches);
		
		TRAINER_LIB_API SCheat(const std::string& name,
			ITrainer* app,
			IMemPatch* patch);

		TRAINER_LIB_API virtual ~SCheat();
		TRAINER_LIB_API virtual void On(HANDLE hProcess);
		TRAINER_LIB_API virtual void Off(HANDLE hProcess);

		TRAINER_LIB_API virtual HotKey* getHotKey() const;

		TRAINER_LIB_API virtual void gameTurnedOff();
		
		virtual inline void addPatch(IMemPatch* patch)
		{patches.push_back(patch);}

		virtual inline void addSMemPatch(unsigned int address, LPVOID newMem, unsigned int cBytes)
		{patches.push_back(new SMemPatch(address, newMem, cBytes));}

		virtual inline void addNopPatch(unsigned int address, unsigned int cBytes)
		{patches.push_back(new NopPatch(address, cBytes));}

		virtual inline bool isEnabled() const
		{return enabled;}

		virtual inline const std::string& getName() const
		{return name;}
	};

}// Namespace TLib